//
//  GetSpotPhotoTask.m
//  ZooNgonDoiOS
//
//  Created by Anh Jun Linh Tinh on 7/4/12.
//  Copyright (c) 2012 Personal. All rights reserved.
//

#import "GetSpotPhotoTask.h"

@implementation GetSpotPhotoTask

-(id)initWithParam:(NSString *)spotId{
    self = [self initWithParam:spotId limit:0 offset:0];
    return self;
}

-(id)initWithParam:(NSString *)spotId limit:(int)limit{
    self = [self initWithParam:spotId limit:limit offset:0];
    return self;
}

-(id)initWithParam:(NSString *)spotId limit:(int)limit offset:(int)offset{
    self = [super init];
    if(self){
        _spotId = spotId;
        _limit = limit;
        _offset = offset;
    }
    return  self;
}

-(void)doExecute{
    NSMutableArray *arrKeys = [[NSMutableArray alloc] init];
    NSMutableArray *arrValues = [[NSMutableArray alloc] init];
    
    [arrKeys addObject:@"spot_id"];
    [arrValues addObject:_spotId];
    
    if (_limit > 0){
        [arrKeys addObject:@"limit"];
         NSString* strLimit = [NSString stringWithFormat:@"%i", _limit];
        [arrValues addObject:strLimit];
    }
    
    if (_offset > 0) {
        [arrKeys addObject:@"offset"];
        NSString* strOffset = [NSString stringWithFormat:@"%i", _offset];
        [arrValues addObject:strOffset];
    }
    NSDictionary *params = [NSDictionary dictionaryWithObjects:arrValues forKeys:arrKeys];
    [[RKObjectManager sharedManager].client get:@"/spot/photo" queryParameters:params delegate:self];
}

-(void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error{
    
}

-(void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response{
    
}

@end
